<?php
	require_once("header.php");
	require_once("dao/timeAttendanceDAO.php");
	
	$originalList = array();
	$approvalList = array();
	
	$result = mysql_query ("SELECT * FROM user INNER JOIN time_attendance ON user.id = time_attendance.id WHERE user.role = 'User' AND user.department = '".$_SESSION['department']."' AND time_attendance.approval_status = '1' ORDER BY time_attendance.id, time_attendance.date ASC") or die (mysql_error());
	
	
	
	$result1 = mysql_query ("SELECT * FROM approval_list INNER JOIN user ON user.id = approval_list.employee_id WHERE user.role = 'User' AND user.department = '".$_SESSION['department']."' AND approval_list.approve_by IS NULL ORDER BY approval_list.employee_id, approval_list.date") or die (mysql_error());
	
	
?>

<div id="body" class="clear">
			<div class="clear">
				<div class="column">
					 <fieldset>
        
                        <legend>Approval List</legend>
                        <form id="approveStaffForm" action="taController.php?request=approve-records&return=<?php echo $domain; ?>/approval.php" method="POST" enctype="multipart/form-data">
                         <table cellspacing="0">
                        		<tbody>
                        			<tr>
                        			    <th>Staff</th>
                            			<th>Date</th>
                            			<th>Official Time</th>
                            			<th>Start Time</th>
                            			<th>End Time</th>        
                            			<th>Break Start</th>
                            			<th>Break End</th>
                            			<th>Day</th>
                            			<th>Approval</th>
        							</tr>
                        <?php while($originalList = mysql_fetch_assoc($result)) {
									$approvalList = mysql_fetch_assoc($result1);
									
									echo "<tr>";
									echo "<td>".$originalList['name']."</td>";
									echo "<td>".$originalList['date']."</td>";
									
									//display for work start time
									//display for start time
									if($originalList['work_start_time'] != $approvalList['work_start_time'])
        								echo "<td>".$originalList['work_start_time']."<font color='green'>-->".$approvalList['work_start_time']."</font></td>";
        							else
        								echo "<td>".$originalList['work_start_time']. "</td>";
									
									//display for start time
									if($originalList['start_time'] != $approvalList['start_time'])
        								echo "<td>".$originalList['start_time']."<font color='green'>-->".$approvalList['start_time']."</font></td>";
        							else
        								echo "<td>".$originalList['start_time']. "</td>";
        									
        							//display for end time	
									if($originalList['end_time'] != $approvalList['end_time'])
        								echo "<td>".$originalList['end_time']."<font color='green'>-->".$approvalList['end_time']."</font></td>";
        							else
        								echo "<td>".$originalList['end_time']. "</td>";
        								
        							//displa for break start
        							if($originalList['break_start'] != $approvalList['break_start'])
        								echo "<td>".$originalList['break_start']."<font color='green'>-->".$approvalList['break_start']."</font></td>";
        							else
        								echo "<td>".$originalList['break_start']. "</td>";
        									
									//dipsplay for break end
									if($originalList['break_end'] != $approvalList['break_end'])
        								echo "<td>".$originalList['break_end']."<font color='green'>-->".$approvalList['break_end']."</font></td>";
        							else
        								echo "<td>".$originalList['break_end']. "</td>";
        								
        							//display for day
        							if($originalList['day'] != $approvalList['day'])
        								echo "<td>".$originalList['day']."<font color='green'>-->".$approvalList['day']."</font></td>";
        							else
        								echo "<td>".$originalList['day']. "</td>";
        								
									echo "<td><input type='checkbox' name='approvalList[]' value='".$originalList['id']."&".$originalList['date']."'/></td>";
									echo "</tr>";
						}?>
						
								</tbody>
      					</table>
      					</br>
      					<p><input name="send" class="formbutton" value="Update" type="submit" style="float:right" /></p>
      					</form>
                        
                     </fieldset>
                 </div>
             </div>
</div>

<?php 
	require_once("footer.php");
?>